using Lzfy_Refund_Service.Models;

namespace Lzfy_Refund_Service.Repositories
{
    /// <summary>
    /// 退款审核工作记录仓储接口
    /// </summary>
    public interface IRefundAcctRepository
    {
        /// <summary>
        /// 根据ID获取退款审核工作记录
        /// </summary>
        /// <param name="id">记录ID</param>
        /// <returns>退款审核工作记录</returns>
        Task<RefundAcct?> GetByIdAsync(int id);

        /// <summary>
        /// 根据结算ID获取退款审核工作记录
        /// </summary>
        /// <param name="acctId">结算ID</param>
        /// <returns>退款审核工作记录</returns>
        Task<RefundAcct?> GetByAcctIdAsync(string acctId);

        /// <summary>
        /// 根据用户名获取退款审核工作记录列表
        /// </summary>
        /// <param name="username">用户名</param>
        /// <returns>退款审核工作记录列表</returns>
        Task<IEnumerable<RefundAcct>> GetByUsernameAsync(string username);

        /// <summary>
        /// 获取所有退款审核工作记录
        /// </summary>
        /// <returns>退款审核工作记录列表</returns>
        Task<IEnumerable<RefundAcct>> GetAllAsync();

        /// <summary>
        /// 分页获取退款审核工作记录
        /// </summary>
        /// <param name="pageNumber">页码</param>
        /// <param name="pageSize">页大小</param>
        /// <param name="username">用户名过滤（可选）</param>
        /// <param name="acctId">结算ID过滤（可选）</param>
        /// <param name="startDate">开始日期过滤（可选）</param>
        /// <param name="endDate">结束日期过滤（可选）</param>
        /// <returns>分页结果</returns>
        Task<(IEnumerable<RefundAcct> Items, int TotalCount)> GetPagedAsync(
            int pageNumber, 
            int pageSize, 
            string? username = null, 
            string? acctId = null, 
            DateTime? startDate = null, 
            DateTime? endDate = null);

        /// <summary>
        /// 创建退款审核工作记录
        /// </summary>
        /// <param name="refundAcct">退款审核工作记录</param>
        /// <returns>创建的记录ID</returns>
        Task<int> CreateAsync(RefundAcct refundAcct);

        /// <summary>
        /// 更新退款审核工作记录
        /// </summary>
        /// <param name="refundAcct">退款审核工作记录</param>
        /// <returns>是否更新成功</returns>
        Task<bool> UpdateAsync(RefundAcct refundAcct);

        /// <summary>
        /// 删除退款审核工作记录
        /// </summary>
        /// <param name="id">记录ID</param>
        /// <returns>是否删除成功</returns>
        Task<bool> DeleteAsync(int id);

        /// <summary>
        /// 检查结算ID是否存在
        /// </summary>
        /// <param name="acctId">结算ID</param>
        /// <returns>是否存在</returns>
        Task<bool> ExistsAsync(string acctId);

        /// <summary>
        /// 获取用户的退款审核工作统计信息
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="startDate">开始日期（可选）</param>
        /// <param name="endDate">结束日期（可选）</param>
        /// <returns>统计信息</returns>
        Task<(int TotalCount, decimal TotalAmount)> GetUserStatisticsAsync(
            string username, 
            DateTime? startDate = null, 
            DateTime? endDate = null);
    }
}